package com.ktgj.flight.controller;

import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.flight.common.spring.SpringService;
import com.ktgj.flight.domain.InterfaceEntity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ControllerAdvice
@RestController
@RequestMapping("/spring")
public class SpringController {
    private static final Logger log = LoggerFactory.getLogger(SpringController.class);

    @Autowired
    private SpringService springService;

    /**
     * 机票查询
     * @param request
     * @return
     */
    @PostMapping("/flightSearch")
    public AjaxResult flightSearch(@RequestBody MoFlightSearchRequest request) {
        MoFlightSearchResponse response = springService.flightSearch(request);
        return AjaxResult.success(response);
    }

    /**
     * 预下单 非会员
     * @param request
     * @return
     */
    @PostMapping("/orderCreateNormal")
    public AjaxResult orderCreateNormal(@RequestBody MoCreateOrderRequest request) {
        MoCreateOrderResponse response = springService.orderCreateNormal(request);
        return AjaxResult.success(response);
    }

    /**
     * 订单查询
     * @param request
     * @return
     */
    @PostMapping("/queryOrderInfo")
    public AjaxResult queryOrderInfo(@RequestBody MoQueryOrderRequest request) {
        MoQueryOrderResponse response = springService.queryOrderInfo(request);
        return AjaxResult.success(response);
    }

    /**
     * 取消订单
     * @param request
     * @return
     */
    @PostMapping("/cancelOrder")
    public AjaxResult cancelOrder(@RequestBody MoCancelOrderRequest request) {
        MoCancelOrderResponse response = springService.cancelOrder(request);
        return AjaxResult.success(response);
    }

    /**
     * 商旅通支付
     * @param request
     * @return
     */
    @PostMapping("/orderPay")
    public AjaxResult orderPay(@RequestBody MoOrderPayRequest request) {
        MoOrderPayResponse response = springService.orderPay(request);
        return AjaxResult.success(response);
    }
}
